/*
 * @Date: 2023-03-14 14:06:50
 * @LastEditTime: 2023-05-10 22:58:24

 * 介绍:tp钱包sdk
 */
/**
 * 获取tp钱包信息
 * @returns
 */
import tp from "tp-js-sdk";
import { sdkSucceed, sdkFail, SdkRes } from "./index";
import { i18n } from "@@/language/index";

//@ts-ignore
const { t } = i18n.global;

export async function sdkWalletPlatformInfo(): Promise<
  SdkRes<WalletPlatformInfoRetrun>
> {
  const failText = "获取tp钱包信息失败";
  if (!tp.isConnected()) return sdkFail(failText);
  const res = await tp.getCurrentWallet();
  if (!res.result) return sdkFail(failText, res);
  return sdkSucceed<WalletPlatformInfoRetrun>("获取tp钱包信息", res.data);
}
export interface WalletPlatformInfoRetrun {
  /**钱包名称 */
  name: string;
  /**钱包地址 */
  address: string;
  /**区块链 */
  blockchain: StrNumber;
  /**区块链id */
  blockchain_id: StrNumber;
  /**节点网址 */
  node: string;
  /*链名称 */
  ns: string;
  walletType: string;
}
